package com.htfyun.ft.fragment.engineer;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.CompoundButton;

import com.htfyun.ft.R;
import com.htfyun.ft.common.FTUtils;
import com.htfyun.ft.fragment.BaseFragment;
import com.htfyun.ft.view.GridSpacingItemDecoration;
import com.htfyun.ft.view.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

/**
 * Created by sst on 2018/7/11.
 */

public class FragmentAgingSettings extends BaseFragment
        implements View.OnClickListener {

    private final static String TAG = "FragmentAgingSettings";

    private RecyclerView recyclerView;

    @Override
    protected int getLayoutRes() {
        return R.layout.fragment_engineer_aging_settings;
    }

    @Override
    protected void onInitView(@Nullable Bundle savedInstanceState) {

        recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.addItemDecoration(new HorizontalDividerItemDecoration
                .Builder(getContext()).color(Color.BLACK).size(1).showLastDivider().build());

        recyclerView.setAdapter(new RecyclerViewAdapterAgingItems(getContext()));

        initBtn(R.id.btnAgingGo);

    }

    private void initBtn(int resId) {
        View btn = findViewById(resId);
        if (btn != null) {
            btn.setOnClickListener(this);
        }
    }

    @Override
    protected void onVisible() {
        super.onVisible();
        if (recyclerView.getAdapter() != null) {
            recyclerView.getAdapter().notifyDataSetChanged();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btnAgingGo:
                FTUtils.startAgingActivityNormal();
                break;
        }

    }

}
